
#include "precomp.h"
#include "program.h"
#include <ClanLib/application.h>
#include "MainMenuDisplay.h"


// Choose the target renderer
#define USE_OPENGL_2
//#define USE_OPENGL_1
//#define USE_SOFTWARE_RENDERER

#ifdef USE_SOFTWARE_RENDERER
#include <ClanLib/swrender.h>
#endif

#ifdef USE_OPENGL_1
#include <ClanLib/gl1.h>
#endif

#ifdef USE_OPENGL_2
#include <ClanLib/gl.h>
#endif

CL_ClanApplication clanapp(&Program::main);

int Program::main(const std::vector<CL_String> &args)
{
	try
	{
		//Initialize core
		CL_SetupCore setup_core;

		//Initialize display
		CL_SetupDisplay setup_display;

		#ifdef USE_SOFTWARE_RENDERER
				CL_SetupSWRender setup_swrender;
		#endif

		#ifdef USE_OPENGL_1
				CL_SetupGL1 setup_gl1;
		#endif

		#ifdef USE_OPENGL_2
				CL_SetupGL setup_gl;
		#endif

		//Initialize GUI
		CL_SetupGUI setup_gui;

		//Initialize sound
		CL_SetupSound setup_sound;

		//Initialize network
		CL_SetupNetwork setup_network;
		
		//Get CSS theme

		CL_String theme;
		if (CL_FileHelp::file_exists("CSS\\theme.css"))
			theme = "CSS";
		else
			throw CL_Exception("Not themes found");

		
		//Initialize GUI Manager , GUI Top Level Description for MainMenu
		CL_GUIManager guiManager(theme);
		CL_GUITopLevelDescription desc;
		desc.set_allow_resize(false);
		desc.show_maximize_button(false);
		
		desc.set_title("Pucca");
		desc.set_size(CL_Size(990,640),true);

		//Start MainMenuDisplay
		MainMenuDisplay mainMenuDisplay(&guiManager,desc);
		

	}
	catch(CL_Exception &exception)
	{
		// Create a console window for text-output if not available
		CL_ConsoleWindow console("Console", 80, 160);
		CL_Console::write_line("Exception caught: " + exception.get_message_and_stack_trace());
		console.display_close_message();

		return -1;
	}

	return 0;
}
